package com.gitee.feizns.quickstart.ding.talk.api.v10.hrm.rosters.lists;

import com.aliyun.dingtalkhrm_1_0.Client;
import com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest;
import com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldResponse;
import com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldResponseBody;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;
import lombok.SneakyThrows;

import java.util.List;

/**
 * 获取员工花名册字段信息
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/api-getemployeerosterbyfield">获取员工花名册字段信息（/v1.0/hrm/rosters/lists/query）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/api-getemployeerosterbyfield">服务端API 智能人事 花名册 获取员工花名册字段信息</a>
 * @author feizns
 * @since 2024/6/30
 */
public class Query {

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param userIdList 用户 ID 列表
     * @param fieldFilterList 字段筛选器列表
     * @param appAgentId 应用代理 ID
     * @param text2SelectConvert text2 选择转换
     * @return {@link List }<{@link GetEmployeeRosterByFieldResponseBody.GetEmployeeRosterByFieldResponseBodyResult }>
     */
    @SneakyThrows
    public static List<GetEmployeeRosterByFieldResponseBody.GetEmployeeRosterByFieldResponseBodyResult> execute(String accessToken, List<String> userIdList, List<String> fieldFilterList, Long appAgentId, Boolean text2SelectConvert) {
        Client client = Clients.get(Client.class);
        GetEmployeeRosterByFieldRequest request = request(userIdList, fieldFilterList, appAgentId, text2SelectConvert);
        GetEmployeeRosterByFieldResponse response = client.getEmployeeRosterByFieldWithOptions(request, headers(accessToken), new RuntimeOptions());
        return response.getBody().getResult();
    }

    /**
     * 请求
     * @param userIdList 用户 ID 列表
     * @param fieldFilterList 字段筛选器列表
     * @param appAgentId 应用代理 ID
     * @param text2SelectConvert text2 选择转换
     * @return {@link com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest }
     */
    public static com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest request(List<String> userIdList, List<String> fieldFilterList, Long appAgentId, Boolean text2SelectConvert) {
        com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest request = new com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest();
        request.setUserIdList(userIdList);
        request.setFieldFilterList(fieldFilterList);
        request.setAppAgentId(appAgentId);
        request.setText2SelectConvert(text2SelectConvert);
        return request;
    }

    /**
     * 请求头
     * @return {@link com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders }
     */
    public static com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders headers(String accessToken) {
        com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders headers = new com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders();
        headers.xAcsDingtalkAccessToken = accessToken;
        return headers;
    }

}
